<div id="panel-button" class="row">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-body text-right">
				<div class="col-sm-4 pull-left">
					{{Form::text('filter', null, array('id' => 'filter', 'class' => 'form-control', 'placeholder' => trans('form.filter')))}}
				</div>
				{{Form::button(trans('form.addnew'), array('class' => 'btn btn-success', 'id' => 'create'))}}
			</div>
		</div>
	</div>
</div>

@if(Session::has('message'))
<div id="panel-error" class="row">
	<div class="col-md-12">
		<div class="panel panel-green panel-minimal">
			<header class="panel-heading">{{trans('form.success')}}</header>
			<div class="panel-body">
				{{Session::get('message')}}
			</div>
		</div>
	</div>
</div>
@endif

<div class="row">
	<div class="col-md-12">
		<div class="panel panel-default">
			<!--<header class="panel-heading">{{trans('brand.brand_list')}}</header>-->
			<div class="panel-body">
				<div class="table-responsive">
					<table class="table table-striped footable" data-filter="#filter" data-page-size="10" data-filter-minimum="1">
						<thead>
							<tr>
								<th data-sort-initial="true" >{{trans('usergroup.name')}}</th>
								<th data-sort-ignore="true">{{trans('usergroup.description')}}</th>
								<th data-type="date">{{trans('form.created_at')}}</th>
								<th data-type="date">{{trans('form.updated_at')}}</th>
								<th data-sort-ignore="true">{{trans('form.tool')}}</th>
							</tr>
						</thead>
						<tbody>
							@foreach($data as $row)
							<tr id="rowdata" data-id="{{$row->id}}">
								<td>{{$row->group}}</td>
								<td>{{$row->description}}</td>
								<td class='col-date' data-value="{{strtotime($row->created_at)}}">{{date("H:i:s d-m-Y", strtotime($row->created_at))}}</td>
								<td class='col-date' data-value="{{strtotime($row->updated_at)}}">{{date("H:i:s d-m-Y", strtotime($row->updated_at))}}</td>
								<td class='col-tool'>
									{{Form::button(trans('form.delete'), array('class' => 'btn btn-mini btn-danger', 'id' => 'delete', 'data-id' => $row->id))}}
								</td>
							</tr>
							@endforeach
						</tbody>
						<tfoot>
							<tr>
								<td colspan="5">
									<ul class="pagination pagination-sm"></ul>
								</td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$('.footable').footable();

	$("button#create").click(function(event) {
		var url = '{{URL::to("admin/user-group/create")}}';

		window.location = url;
	});

	$("button#delete").click(function(event) {
		var ok = confirm('{{trans('form.confirmdelete')}}');

		if(ok){
			var id = $(this).attr('data-id');
			var url = '{{URL::to("admin/user-group/delete/")}}' + '/' + id;

			window.location = url;
		}

		return false;
	});

	$("tr#rowdata").click(function(event) {
		var id = $(this).attr('data-id');
		var url = '{{URL::to("admin/user-group/edit/")}}' + '/' + id;

		window.location = url;
	});
});
</script>